/**
 * Created by subo on 16/4/20.
 */
var shop_home_titles = ["巴黎", "推荐", "商店"];
var shophome_tab_shoplist = "#shophome_tab_shoplist";
var shophome_tab_recommend = "#shophome_tab_recommend";
var shops = {};
function initShopHomePage() {
    listShops(function(data){
        shops = data;
        var shopListRootDiv = $('#shophome_tab_shoplist');
        var shopDiv = $('#shop_detailHomeLink1');
        shopDiv.remove();
        for (var i = 0; i < shops.length; i++) {
            shopDiv = shopDiv.clone();
            shopDiv.attr('id', shops[i].shopId);
            var shopName = shopDiv.find('span');
            var shopIcon = shopDiv.find('img');
            var shopCnName = shops[i].shopNameCn;
            var shopImgSrc = shops[i].shopIcon;
            shopIcon.attr('alt', shopCnName);
            shopIcon.attr('src', shopImgSrc);
            shopName.html(shopCnName);
            shopDiv.appendTo(shopListRootDiv)
        }
        shopDetailPageIndex();
    })
}
function shopDetailPageIndex(){
    var shopListRootDiv = $('#shophome_tab_shoplist');
    var shopsDivs = shopListRootDiv.children('div');
    for (var i = 0; i < shopsDivs.length; i++) {
        $('#'+shopsDivs[i].id).on('tap', function () {
            navToShopDetails(shopHomeIndex.shop_detail);
        });
    }
}

var shopHomeIndex = {'shop_detail':1};
function navToShopDetails(i) {
    var page_content = $("div[data-role='content']");
    switch (i) {
        case shopHomeIndex.shop_detail:
            document.title = '商店详情';
            loadTitleBar1_r1(shop_detail_titles);
            loadBottomBar(bottom_bar_titles);
            page_content.load('shop_detail/shop_detail.html', function(){
                registerShopDetailTapEvent();
            });
            break;

    }
}